<template>
    <div>
        <h3><slot name=title></slot></h3>
        <figure><img src="./images/001.png"></figure>
        <ul>
            <p>
                <slot></slot>...
            </p>
            <a title="/"
               class="readmore" @click="gotoArticle()">阅读全文>></a>
        </ul>
        <p class="dateview">
            <slot name='created_at'></slot>
            <slot name='user'></slot>
        </p>
    </div>
</template>
<script>
export default {
    data() {
        return {
           
        }
    },
    props: {
        user: {
            default: '杨青'
        },
        articleId:{
            default:1
        }
    },
    methods:{
        gotoArticle(){
            console.log('hello world')
            let data={
                id:this.articleId,
                title:'',
                body:'',
                'created_at':'',
                username:''
                
            }
            window.axios({
                url: 'api/article/' + this.articleId + '/edit',
                method: 'get',
            }).then((res) => {
                data.id = res.data['id'];
                data.title = res.data['title'];
                data.body = res.data['body'];
                data.username=res.data['username'];
                data.createAt=res.data['created_at'];
                this.$store.commit('updated',data);
                this.$router.push({path:'article'})
            })
        //     //this.$store.
        // }
        }
    }
}
</script>